package com.xhwl.logistics.service.business;


import com.xhwl.common.exception.BusinessException;
import com.xhwl.common.pojo.cent.sdata.Project;
import com.xhwl.common.query.cent.sdata.ProjectQuery;
import com.xhwl.logistics.entity.*;
import com.xhwl.logistics.service.cent.IProjectService;
import com.xhwl.logistics.service.impl.*;
import com.xhwl.logistics.util.MathUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.ListUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * 车行服务中一些常用的服务
 */
@Slf4j
//@Service
public class VehicleCommonBusinessService {

    @Autowired
    private IProjectService projectService;

    @Autowired
    private VehicleParkingLotServiceImpl vehicleParkingLotService;

    @Autowired
    private VehicleAreaServiceImpl vehicleAreaService;

    @Autowired
    private VehiclePassageServiceImpl vehiclePassageService;

    @Autowired
    private VehicleCardServiceImpl vehicleCardService;

    @Autowired
    private VehicleCarServiceImpl vehicleCarService;

    /**
     * 通过项目id获取项目实体类Project
     */
    public Project getProjectById(Integer projectId){
        ProjectQuery projectQuery = new ProjectQuery();
        LinkedList<Integer> ids = new LinkedList<>();
        ids.add(projectId);
        projectQuery.setIds(ids);
        Project project = projectService.getOne(projectQuery, null);
        return project;
    }

    /**
     * 将中台的车场信息同步成第三方车场信息一样
     */
    public void syncParkingLot(List<VehicleParkingLot> oldVehicleParkingLot, List<VehicleParkingLot> newVehicleParkingLot){
        log.info("车场信息同步中。。。");
        Map<String, VehicleParkingLot> mapForParkingLotFromCent = new HashMap<>();
        Map<String, VehicleParkingLot> mapForParkingLotFromThird = new HashMap<>();

        List<String> thridIdFromCent = oldVehicleParkingLot.stream().map(s -> s.getParkId()).collect(Collectors.toList());
        try{
            mapForParkingLotFromCent = oldVehicleParkingLot.stream().collect(
                    Collectors.toMap(s -> s.getParkId(), Function.identity())
            );
        }catch (Exception e){
            throw new BusinessException("已入库的车场信息存在重复的第三方车场id");
        }

        List<String> thirdIdFromThird = newVehicleParkingLot.stream().map(s -> s.getParkId()).collect(Collectors.toList());
        try{
            mapForParkingLotFromThird = newVehicleParkingLot.stream().collect(
                    Collectors.toMap(s -> s.getParkId(), Function.identity())
            );
        }catch (Exception e){
            throw new BusinessException("获取到的车场信息中存在重复的第三方车场id");
        }

        List<String> add = ListUtils.subtract(thirdIdFromThird, thridIdFromCent);
        if(!add.isEmpty()){
            List<VehicleParkingLot> vehicleParkingLotList = add.stream().map(mapForParkingLotFromThird::get).collect(Collectors.toList());
            vehicleParkingLotService.saveBatch(vehicleParkingLotList);
        }

        List<String> delete = ListUtils.subtract(thridIdFromCent, thirdIdFromThird);
        if(!delete.isEmpty()){
            List<VehicleParkingLot> vehicleParkingLotList = delete.stream().map(mapForParkingLotFromCent::get).collect(Collectors.toList());
            List<Integer> ids = vehicleParkingLotList.stream().map(s -> s.getId()).collect(Collectors.toList());
            vehicleParkingLotService.removeByIds(ids);
        }

        List<String> update = ListUtils.subtract(thridIdFromCent, delete);
        if(!update.isEmpty()){
            LinkedList<VehicleParkingLot> vehicleParkingLots = new LinkedList<>();
            for (String thirdId : update) {
                VehicleParkingLot vehicleParkingLotFromCent = mapForParkingLotFromCent.get(thirdId);
                VehicleParkingLot vehicleParkingLotFromThird = mapForParkingLotFromThird.get(thirdId);
                if(!isSameParkingLot(vehicleParkingLotFromCent,vehicleParkingLotFromThird)){
                    vehicleParkingLots.add(copyParkingLotFromThird(vehicleParkingLotFromCent,vehicleParkingLotFromThird));
                }
            }
            vehicleParkingLotService.updateBatchById(vehicleParkingLots);
        }
        log.info("车场信息同步结束！");
    }

    /**
     * 将中台的区域信息同步成第三方区域信息一样
     */
    public void syncArea(List<VehicleArea> oldVehicleAreaList, List<VehicleArea> newVehicleAreaList){
        log.info("同步区域中。。。");
        Map<String, VehicleArea> mapForAreaFromCent = new HashMap<>();
        Map<String, VehicleArea> mapForAreaFromThird = new HashMap<>();

        List<String> thridIdFromCent = oldVehicleAreaList.stream().map(s -> s.getThirdAreaId()).collect(Collectors.toList());
        try{
            mapForAreaFromCent = oldVehicleAreaList.stream().collect(
                    Collectors.toMap(s -> s.getThirdAreaId(), Function.identity())
            );
        }catch (Exception e){
            throw new BusinessException("已入库的区域信息存在重复的第三方id");
        }

        List<String> thirdIdFromThird = newVehicleAreaList.stream().map(s -> s.getThirdAreaId()).collect(Collectors.toList());
        try{
            mapForAreaFromThird = newVehicleAreaList.stream().collect(
                    Collectors.toMap(s -> s.getThirdAreaId(), Function.identity())
            );
        }catch (Exception e){
            throw new BusinessException("获取到的区域信息中存在重复的第三方id");
        }

        List<String> add = ListUtils.subtract(thirdIdFromThird, thridIdFromCent);
        if(!add.isEmpty()){
            List<VehicleArea> vehicleAreaList = add.stream().map(mapForAreaFromThird::get).collect(Collectors.toList());
            vehicleAreaService.saveBatch(vehicleAreaList);
        }

        List<String> delete = ListUtils.subtract(thridIdFromCent, thirdIdFromThird);
        if(!delete.isEmpty()){
            List<VehicleArea> vehicleAreaList = delete.stream().map(mapForAreaFromCent::get).collect(Collectors.toList());
            List<Integer> ids = vehicleAreaList.stream().map(s -> s.getId()).collect(Collectors.toList());
            vehicleAreaService.removeByIds(ids);
        }

        List<String> update = ListUtils.subtract(thridIdFromCent, delete);
        if(!update.isEmpty()){
            LinkedList<VehicleArea> vehicleAreas = new LinkedList<>();
            for (String thirdId : update) {
                VehicleArea vehicleAreaFromCent = mapForAreaFromCent.get(thirdId);
                VehicleArea vehicleAreaFromThird = mapForAreaFromThird.get(thirdId);
                if(!isSameArea(vehicleAreaFromCent,vehicleAreaFromThird)){
                    vehicleAreas.add(copyAreaFromThird(vehicleAreaFromCent,vehicleAreaFromThird));
                }
            }
            vehicleAreaService.updateBatchById(vehicleAreas);
        }
        log.info("区域信息同步结束！");
    }

    /**
     * 将中台的通道信息同步成第三方通道信息一样
     */
    public void syncPassage(List<VehiclePassage> oldVehiclePassageList, List<VehiclePassage> newVehiclePassageList){
        log.info("同步通道信息中。。。");
        Map<String, VehiclePassage> mapForPassageFromCent = new HashMap<>();
        Map<String, VehiclePassage> mapForPassageFromThird = new HashMap<>();

        List<String> thridIdFromCent = oldVehiclePassageList.stream().map(s -> s.getThirdPassageId()).collect(Collectors.toList());
        try{
            mapForPassageFromCent = oldVehiclePassageList.stream().collect(
                    Collectors.toMap(s -> s.getThirdPassageId(), Function.identity())
            );
        }catch (Exception e){
            throw new BusinessException("已入库的通道信息存在重复的第三方id");
        }

        List<String> thirdIdFromThird = newVehiclePassageList.stream().map(s -> s.getThirdPassageId()).collect(Collectors.toList());
        try{
            mapForPassageFromThird = newVehiclePassageList.stream().collect(
                    Collectors.toMap(s -> s.getThirdPassageId(), Function.identity())
            );
        }catch (Exception e){
            throw new BusinessException("获取到的通道信息中存在重复的第三方id");
        }

        List<String> add = ListUtils.subtract(thirdIdFromThird, thridIdFromCent);
        if(!add.isEmpty()){
            List<VehiclePassage> vehiclePassageList = add.stream().map(mapForPassageFromThird::get).collect(Collectors.toList());
            vehiclePassageService.saveBatch(vehiclePassageList);
        }

        List<String> delete = ListUtils.subtract(thridIdFromCent, thirdIdFromThird);
        if(!delete.isEmpty()){
            List<VehiclePassage> vehiclePassageList = delete.stream().map(mapForPassageFromCent::get).collect(Collectors.toList());
            List<Integer> ids = vehiclePassageList.stream().map(s -> s.getId()).collect(Collectors.toList());
            vehiclePassageService.removeByIds(ids);
        }

        List<String> update = ListUtils.subtract(thridIdFromCent, delete);
        if(!update.isEmpty()){
            LinkedList<VehiclePassage> vehiclePassages = new LinkedList<>();
            for (String thirdId : update) {
                VehiclePassage vehiclePassageFromCent = mapForPassageFromCent.get(thirdId);
                VehiclePassage vehiclePassageFromThird = mapForPassageFromThird.get(thirdId);
                if(!isSamePassage(vehiclePassageFromCent,vehiclePassageFromThird)){
                    vehiclePassages.add(copyPassageFromThird(vehiclePassageFromCent,vehiclePassageFromThird));
                }
            }
            vehiclePassageService.updateBatchById(vehiclePassages);
        }
        log.info("通道信息同步结束！");
    }

    /**
     * 将中台的车卡类型信息同步成第三方车卡类型信息一样
     */
    public void syncCardType(List<VehicleCard> oldVehicleCardList, List<VehicleCard> newVehicleCardList){
        log.info("同步车卡类型中。。。");
        Map<String, VehicleCard> mapForCardFromCent = new HashMap<>();
        Map<String, VehicleCard> mapForCardFromThird = new HashMap<>();

        List<String> thirdIdFromCent = oldVehicleCardList.stream().map(VehicleCard::getThirdRuleId).collect(Collectors.toList());
        try{
            mapForCardFromCent = oldVehicleCardList.stream().collect(
                    Collectors.toMap(VehicleCard::getThirdRuleId, Function.identity())
            );
        }catch (Exception e){
            throw new BusinessException("已入库的车卡类型信息存在重复的第三方id");
        }

        List<String> thirdIdFromThird = newVehicleCardList.stream().map(VehicleCard::getThirdRuleId).collect(Collectors.toList());
        try {
            mapForCardFromThird = newVehicleCardList.stream().collect(
                    Collectors.toMap(VehicleCard::getThirdRuleId,Function.identity())
            );
        }catch (Exception e){
            throw new BusinessException("获取到的车卡类型信息存在重复的第三方id");
        }

        List<String> add = ListUtils.subtract(thirdIdFromThird, thirdIdFromCent);
        if(!add.isEmpty()){
            List<VehicleCard> vehicleCards = add.stream().map(mapForCardFromThird::get).collect(Collectors.toList());
            vehicleCardService.saveBatch(vehicleCards);
        }

        List<String> delete = ListUtils.subtract(thirdIdFromCent, thirdIdFromThird);
        if(!delete.isEmpty()){
            List<VehicleCard> vehicleCards = delete.stream().map(mapForCardFromCent::get).collect(Collectors.toList());
            List<Integer> ids = vehicleCards.stream().map(VehicleCard::getId).collect(Collectors.toList());
            vehicleCardService.removeByIds(ids);
        }

        List<String> update = ListUtils.subtract(thirdIdFromCent, delete);
        if(!update.isEmpty()){
            List<VehicleCard> vehicleCards = new LinkedList<>();
            for (String thirdId : update) {
                VehicleCard vehicleCardFromCent = mapForCardFromCent.get(thirdId);
                VehicleCard vehicleCardFromThird = mapForCardFromThird.get(thirdId);
                if(!isSameCard(vehicleCardFromCent,vehicleCardFromThird)){
                    VehicleCard vehicleCard = copyCardFromThird(vehicleCardFromCent, vehicleCardFromThird);
                    vehicleCards.add(vehicleCard);
                }
            }
            vehicleCardService.updateBatchById(vehicleCards);
        }

        log.info("车卡信息同步结束！");
    }

    /**
     * 将中台的车辆信息同步成第三方车辆信息一样
     */
    public void syncCar(List<VehicleCar> oldVehicleCarList, List<VehicleCar> newVehicleCarList){
        log.info("同步车辆信息中。。。");
        Map<String, VehicleCar> mapForCarFromCent = new HashMap<>();
        Map<String, VehicleCar> mapForCarFromThird = new HashMap<>();

        List<String> plateNumberFromCent = oldVehicleCarList.stream().map(VehicleCar::getPlateNumber).collect(Collectors.toList());
        try{
            mapForCarFromCent = oldVehicleCarList.stream().collect(
                    Collectors.toMap(VehicleCar::getPlateNumber, Function.identity()));
        }catch (Exception e){
            throw new BusinessException("该项目下已入库的车辆信息中存在多个相同的车牌号！");
        }

        List<String> plateNumberFromThird = newVehicleCarList.stream().map(VehicleCar::getPlateNumber).collect(Collectors.toList());
        try {
            mapForCarFromThird = newVehicleCarList.stream().collect(
                    Collectors.toMap(VehicleCar::getPlateNumber, Function.identity())
            );
        }catch (Exception e){
            throw new BusinessException("获取到的车辆信息中存在多个相同的车牌号！");
        }

        List<String> add = ListUtils.subtract(plateNumberFromThird, plateNumberFromCent);
        if(!add.isEmpty()){
            List<VehicleCar> vehicleCars = add.stream().map(mapForCarFromThird::get).collect(Collectors.toList());
            vehicleCarService.saveBatch(vehicleCars);
        }

        List<String> delete = ListUtils.subtract(plateNumberFromCent, plateNumberFromThird);
        if(!delete.isEmpty()){
            List<VehicleCar> vehicleCars = delete.stream().map(mapForCarFromCent::get).collect(Collectors.toList());
            List<Integer> ids = vehicleCars.stream().map(VehicleCar::getId).collect(Collectors.toList());
            vehicleCarService.removeByIds(ids);
        }

        List<String> update = ListUtils.subtract(plateNumberFromCent, delete);
        if(!update.isEmpty()){
            List<VehicleCar> vehicleCars = new LinkedList<>();
            for (String plateNumber : update) {
                VehicleCar vehicleCarFromCent = mapForCarFromCent.get(plateNumber);
                VehicleCar vehicleCarFromThird = mapForCarFromThird.get(plateNumber);
                if(!isSameCar(vehicleCarFromCent,vehicleCarFromThird)){
                    vehicleCars.add(copyCarFromThird(vehicleCarFromCent,vehicleCarFromThird));
                }
            }
            vehicleCarService.updateBatchById(vehicleCars);
        }

        log.info("车辆信息同步结束！");
    }

    /**
     * 按recordId对VehicleAccessRecord去重
     */
    public List<VehicleAccessRecord> filterVehicleAccessRecordByRecordId(List<VehicleAccessRecord> vehicleAccessRecords){
        LinkedList<VehicleAccessRecord> vehicleAccessRecordsNew = new LinkedList<>();
        for (VehicleAccessRecord vehicleAccessRecord : vehicleAccessRecords) {
            VehicleAccessRecord vehicleAccessRecordNew = vehicleAccessRecordsNew.stream().filter(s -> {
                if (StringUtils.equals(s.getRecordId(), vehicleAccessRecord.getRecordId())) {
                    return true;
                } else {
                    return false;
                }
            }).findAny().orElse(null);
            if(vehicleAccessRecordNew==null){
                vehicleAccessRecordsNew.add(vehicleAccessRecord);
            }
        }
        return vehicleAccessRecordsNew;
    }

    /**
     * 根据recordId来获取新的VehicleAccessRecordList比老的多了的VehicleAccessRecordList
     */
    public List<VehicleAccessRecord> compareVehicleAccessRecordByRecordId(List<VehicleAccessRecord> oldVehicleAccessRecordList, List<VehicleAccessRecord> newVehicleAccessRecordList){
        List<VehicleAccessRecord> oldVehicleAccessRecords = this.filterVehicleAccessRecordByRecordId(oldVehicleAccessRecordList);
        List<VehicleAccessRecord> newVehicleAccessRecords = this.filterVehicleAccessRecordByRecordId(newVehicleAccessRecordList);

        List<String> recordIdFromOld = oldVehicleAccessRecords.stream().map(s -> s.getRecordId()).collect(Collectors.toList());

        List<String> recordIdFromNew = newVehicleAccessRecords.stream().map(s -> s.getRecordId()).collect(Collectors.toList());
        Map<String, VehicleAccessRecord> mapForNew = newVehicleAccessRecords.stream().collect(Collectors.toMap(s -> s.getRecordId(), Function.identity()));

        List<String> add = ListUtils.subtract(recordIdFromNew, recordIdFromOld);
        List<VehicleAccessRecord> vehicleAccessRecords = new LinkedList<>();
        if(!add.isEmpty()){
            vehicleAccessRecords = add.stream().map(mapForNew::get).collect(Collectors.toList());
        }
        return vehicleAccessRecords;
    }

    /**
     * 按billId对VehiclePayRecord去重
     */
    public List<VehiclePayRecord> filterVehiclePayRecordByBillId(List<VehiclePayRecord> vehiclePayRecords){
        LinkedList<VehiclePayRecord> vehiclePayRecordsNew = new LinkedList<>();
        for (VehiclePayRecord vehiclePayRecord : vehiclePayRecords) {
            VehiclePayRecord vehiclePayRecordnew = vehiclePayRecordsNew.stream().filter(s -> {
                if (StringUtils.equals(s.getAccessRecordId(), vehiclePayRecord.getAccessRecordId())) {
                    return true;
                } else {
                    return false;
                }
            }).findAny().orElse(null);
            if(vehiclePayRecordnew==null){
                vehiclePayRecordsNew.add(vehiclePayRecord);
            }
        }
        return vehiclePayRecordsNew;
    }

    /**
     * 根据billId来获取新的VehiclePayRecordList比老的多了的VehiclePayRecordList
     */
    public List<VehiclePayRecord> compareVehiclePayRecordByBillId(List<VehiclePayRecord> oldVehiclePayRecordList, List<VehiclePayRecord> newVehiclePayRecordList){
        List<VehiclePayRecord> oldVehiclePayRecords = this.filterVehiclePayRecordByBillId(oldVehiclePayRecordList);
        List<VehiclePayRecord> newVehiclePayRecords = this.filterVehiclePayRecordByBillId(newVehiclePayRecordList);

        List<String> billIdFromOld = oldVehiclePayRecords.stream().map(s -> s.getAccessRecordId()).collect(Collectors.toList());

        List<String> billIdFromNew = newVehiclePayRecords.stream().map(s -> s.getAccessRecordId()).collect(Collectors.toList());
        Map<String, VehiclePayRecord> mapForNew = newVehiclePayRecords.stream().collect(Collectors.toMap(s -> s.getAccessRecordId(), Function.identity()));

        List<String> add = ListUtils.subtract(billIdFromNew, billIdFromOld);
        List<VehiclePayRecord> vehiclePayRecords = new LinkedList<>();
        if(!add.isEmpty()){
            vehiclePayRecords = add.stream().map(mapForNew::get).collect(Collectors.toList());
        }
        return vehiclePayRecords;
    }

    /**
     * 比较中台车场信息与第三方车场信息是否相同
     */
    private Boolean isSameParkingLot(VehicleParkingLot vehicleParkingLotFromCent, VehicleParkingLot vehicleParkingLotFromThird){
        if(StringUtils.equals(vehicleParkingLotFromCent.getParkingLotName(),vehicleParkingLotFromThird.getParkingLotName())&&
        MathUtil.equalsInterger(vehicleParkingLotFromCent.getCarportTotalNumber(),vehicleParkingLotFromThird.getCarportTotalNumber(),true, "同步时，车场车位数量信息为空！")){
            return true;
        }else{
            return false;
        }
    }

    /**
     * 将第三方车场信息赋值到中台车场信息
     */
    private VehicleParkingLot copyParkingLotFromThird(VehicleParkingLot vehicleParkingLotFromCent, VehicleParkingLot vehicleParkingLotFromThird){
        vehicleParkingLotFromCent.setParkingLotName(vehicleParkingLotFromThird.getParkingLotName());
        vehicleParkingLotFromCent.setCarportTotalNumber(vehicleParkingLotFromThird.getCarportTotalNumber());
        return vehicleParkingLotFromCent;
    }

    /**
     * 比较中台区域信息与第三方区域信息是否相同
     */
    private Boolean isSameArea(VehicleArea vehicleAreaFromCent, VehicleArea vehicleAreaFromThird){
        if(StringUtils.equals(vehicleAreaFromCent.getAreaName(),vehicleAreaFromThird.getAreaName())&&
        MathUtil.equalsInterger(vehicleAreaFromCent.getCarportTotalNumber(),vehicleAreaFromThird.getCarportTotalNumber(),true,"同步时，区域车位数量信息为空！")&&
        StringUtils.equals(vehicleAreaFromCent.getRemark(),vehicleAreaFromThird.getRemark())){
            return true;
        }else{
            return false;
        }
    }

    /**
     * 将第三方区域信息赋值到中台区域信息
     */
    private VehicleArea copyAreaFromThird(VehicleArea vehicleAreaFromCent, VehicleArea vehicleAreaFromThird){
        vehicleAreaFromCent.setAreaName(vehicleAreaFromThird.getAreaName());
        vehicleAreaFromCent.setCarportTotalNumber(vehicleAreaFromThird.getCarportTotalNumber());
        vehicleAreaFromCent.setRemark(vehicleAreaFromThird.getRemark());
        return vehicleAreaFromCent;
    }

    /**StringUtils.equals(vehiclePassageFromCent.getType().toString(),vehiclePassageFromThird.getType().toString())
     * 比较中台通道信息与第三方通道信息是否相同
     */
    private Boolean isSamePassage(VehiclePassage vehiclePassageFromCent, VehiclePassage vehiclePassageFromThird){
        if(StringUtils.equals(vehiclePassageFromCent.getPassageName(),vehiclePassageFromThird.getPassageName())&&
        MathUtil.equalsInterger(vehiclePassageFromCent.getType(),vehiclePassageFromThird.getType(),true,"同步时，通道出入类型为空！")&&
        StringUtils.equals(vehiclePassageFromCent.getRemark(),vehiclePassageFromThird.getRemark())){
            return true;
        }else{
            return false;
        }
    }

    /**
     * 将第三方通道信息赋值到中台通道信息
     */
    private VehiclePassage copyPassageFromThird(VehiclePassage vehiclePassageFromCent, VehiclePassage vehiclePassageFromThird){
        vehiclePassageFromCent.setPassageName(vehiclePassageFromThird.getPassageName());
        vehiclePassageFromCent.setType(vehiclePassageFromThird.getType());
        vehiclePassageFromCent.setRemark(vehiclePassageFromThird.getRemark());
        return vehiclePassageFromCent;
    }

    /**
     * 比较中台车卡信息与第三方车卡信息是否相同
     */
    private Boolean isSameCard(VehicleCard vehicleCardFromCent, VehicleCard vehicleCardFromThird){
        if(StringUtils.equals(vehicleCardFromCent.getName(),vehicleCardFromThird.getName())&&
        MathUtil.equalsInterger(vehicleCardFromCent.getCardType(),vehicleCardFromThird.getCardType(),true,"同步时，卡类型信息为空！")&&
        StringUtils.equals(vehicleCardFromCent.getChargeRule(),vehicleCardFromThird.getChargeRule())&&
        MathUtil.equalsInterger(vehicleCardFromCent.getRechargeMoney(),vehicleCardFromThird.getRechargeMoney(),false,"")){
            return true;
        }else{
            return false;
        }
    }

    /**
     * 将第三方车卡信息赋值到中台车卡信息
     */
    private VehicleCard copyCardFromThird(VehicleCard vehicleCardFromCent, VehicleCard vehicleCardFromThird){
        vehicleCardFromCent.setName(vehicleCardFromThird.getName());
        vehicleCardFromCent.setCardType(vehicleCardFromThird.getCardType());
        vehicleCardFromCent.setChargeRule(vehicleCardFromThird.getChargeRule());
        vehicleCardFromCent.setRechargeMoney(vehicleCardFromThird.getRechargeMoney());
        vehicleCardFromCent.setEditorAccountName(vehicleCardFromThird.getEditorAccountName());
        return vehicleCardFromCent;
    }

    /**
     * 比较中台车辆信息与第三方车辆信息是否相同
     */
    private Boolean isSameCar(VehicleCar vehicleCarFromCent, VehicleCar vehicleCarFromThird){
        if(StringUtils.equals(vehicleCarFromCent.getPlateNumber(),vehicleCarFromThird.getPlateNumber())&&
        StringUtils.equals(vehicleCarFromCent.getCarColor(),vehicleCarFromThird.getCarColor())&&
        MathUtil.equalsInterger(vehicleCarFromCent.getCarType(),vehicleCarFromThird.getCarType(),false,"")&&
        MathUtil.equalsInterger(vehicleCarFromCent.getCardType(),vehicleCarFromThird.getCardType(),true,"同步时，车辆的车卡信息为空！")&&
        StringUtils.equals(vehicleCarFromCent.getOwnerName(),vehicleCarFromThird.getOwnerName())&&
        StringUtils.equals(vehicleCarFromCent.getOwnerPhone(),vehicleCarFromThird.getOwnerPhone())&&
        MathUtil.equalsInterger(vehicleCarFromCent.getOwnerAccountId(),vehicleCarFromThird.getOwnerAccountId(),false,"")){
            return true;
        }else{
            return false;
        }
    }

    /**
     * 将第三方车辆信息赋值到中台车辆信息
     */
    private VehicleCar copyCarFromThird(VehicleCar vehicleCarFromCent, VehicleCar vehicleCarFromThird){
        vehicleCarFromCent.setPlateNumber(vehicleCarFromThird.getPlateNumber());
        vehicleCarFromCent.setCarColor(vehicleCarFromThird.getCarColor());
        vehicleCarFromCent.setCarType(vehicleCarFromThird.getCarType());
        vehicleCarFromCent.setCardType(vehicleCarFromThird.getCardType());
        vehicleCarFromCent.setOwnerName(vehicleCarFromThird.getOwnerName());
        vehicleCarFromCent.setOwnerPhone(vehicleCarFromThird.getOwnerPhone());
        vehicleCarFromCent.setOwnerAccountId(vehicleCarFromThird.getOwnerAccountId());
        vehicleCarFromCent.setEditorAccountName(vehicleCarFromThird.getEditorAccountName());
        return vehicleCarFromCent;
    }

}
